﻿@model IList<XStudio.Framework.Support.Entity.User.EmployeeEntity>
<script src="@Url.Content("~/Scripts/plugins/PasswordStrength/PasswordStrength.js")" type="text/javascript"></script>
<div style="margin: 10px; padding: 5px;">
    <div class="tip-alert-box" id="receiveUse">
        <p>
            <strong>〓 选中员工(@(Model.Count)个)：</strong></p>
        <p>
            @foreach (var item in Model)
            {
                <span class="btn-user">@item.EmployeeName</span>
            }
        </p>
    </div>
    <form name="frmReset" id="frmReset" method="post" action="@Request.Url">
    <table class="tbl-input" cellspacing="0" style="width: 100%;">
        <colgroup>
            <col style="width: 100px;" />
            <col class="w4" />
            <col />
        </colgroup>
        <tbody>
            <tr>
                <th scope="row">
                    登录密码：
                </th>
                <td>
                    @Html.Password("Password", "", new { width = "100px", maxlength = "25" })
                </td>
                <td class="slight">
                    <span class="btn-infomust">必填项。</span>
                </td>
            </tr>
            <tr>
                <th scope="row">
                    确认密码：
                </th>
                <td>
                    @Html.Password("ConfirmPassword", "", new { width = "100px", maxlength = "25" })
                </td>
                <td class="slight">
                    <span class="btn-infomust">必填项。</span>
                </td>
            </tr>
            <tr>
                <td colspan="3">
                    <div class="lineSolid" style="margin: 5px;">
                    </div>
                    <div style="padding: 15px; text-align: center">
                        <input type="button" value="保存" onclick="Reset.Save(this)" class="btn-8" />
                        <span>&nbsp;&nbsp;&nbsp;&nbsp;</span>
                        <input type="button" value="返回" onclick="Reset.Back(this)" class="btn-8" />
                    </div>
                </td>
            </tr>
        </tbody>
    </table>
    </form>
</div>
<script type="text/javascript">
    var Reset = {};

    $(document).ready(function () {
        Common.BindWarp();
        $("#Password").pstrength();

        //表单验证
        var v = $("#frmReset").validate({
            focusInvalid: true,
            rules: {
                Password: { required: true },
                ConfirmPassword: { required: true, equalTo: "#Password" }

            },
            messages: {
                Password: { required: "请输入密码！" },
                ConfirmPassword: { required: "请输入确认密码！", equalTo: "两次密码不一致！" }
            }
        });
    });


    Reset.Save = function (e) {
        if (!$("#frmReset").valid()) {
            return;
        }
         
        if (!confirm("确认要重置选中用户的登录密码吗？"))
            return;

        var frm = $(e).parents("form");
        $.ajax({
            url: $(frm).attr("action"),
            data: $(frm).serialize(),
            type: "Post",
            error: function (request) {
                alert('重置密码出错，请重试！');
            },
            success: function (data) {
                if (data.IsOK) {
                    $.closeWin(e);
                }
                else
                    alert(data.Description);
            }
        });
    }
    Reset.Back = function (e) {
        $.closeWin(e);
    }
</script>
